package com.hgy.carsb.entity;

import lombok.Data;

import java.math.BigDecimal;

@Data
public class UnitAnalysisDetail {
    private String thisMonth;
    private String lastMonth;
    private String subMonth;
    private String monthRate;

    public UnitAnalysisDetail(String thisMonth, String lastMonth){
        this.thisMonth = thisMonth;
        this.lastMonth = lastMonth;
        BigDecimal subMonth = new BigDecimal(thisMonth).subtract(new BigDecimal(lastMonth));
        this.subMonth = subMonth.toString();
        if (lastMonth.equals("0")){
            this.monthRate = "0";
        }else {
            this.monthRate = subMonth.multiply(new BigDecimal(100)).divide(new BigDecimal(lastMonth), 2, BigDecimal.ROUND_HALF_UP).toString();
        }

    }
}
